package com.ruoyi.poring.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.poring.domain.ErpReceivableMonthlyReport;
import com.ruoyi.poring.service.IErpReceivableMonthlyReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应收款月份报Controller
 * 
 * @author ruoyi
 * @date 2025-08-01
 */
@RestController
@RequestMapping("/poring/poring")
public class ErpReceivableMonthlyReportController extends BaseController
{
    @Autowired
    private IErpReceivableMonthlyReportService erpReceivableMonthlyReportService;

    /**
     * 查询应收款月份报列表
     */
    @PreAuthorize("@ss.hasPermi('poring:poring:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpReceivableMonthlyReport erpReceivableMonthlyReport)
    {
        startPage();
        List<ErpReceivableMonthlyReport> list = erpReceivableMonthlyReportService.selectErpReceivableMonthlyReportList(erpReceivableMonthlyReport);
        return getDataTable(list);
    }

    /**
     * 导出应收款月份报列表
     */
    @PreAuthorize("@ss.hasPermi('poring:poring:export')")
    @Log(title = "应收款月份报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpReceivableMonthlyReport erpReceivableMonthlyReport)
    {
        List<ErpReceivableMonthlyReport> list = erpReceivableMonthlyReportService.selectErpReceivableMonthlyReportList(erpReceivableMonthlyReport);
        ExcelUtil<ErpReceivableMonthlyReport> util = new ExcelUtil<ErpReceivableMonthlyReport>(ErpReceivableMonthlyReport.class);
        util.exportExcel(response, list, "应收款月份报数据");
    }

    /**
     * 获取应收款月份报详细信息
     */
    @PreAuthorize("@ss.hasPermi('poring:poring:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(erpReceivableMonthlyReportService.selectErpReceivableMonthlyReportById(id));
    }

    /**
     * 新增应收款月份报
     */
    @PreAuthorize("@ss.hasPermi('poring:poring:add')")
    @Log(title = "应收款月份报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpReceivableMonthlyReport erpReceivableMonthlyReport)
    {
        return toAjax(erpReceivableMonthlyReportService.insertErpReceivableMonthlyReport(erpReceivableMonthlyReport));
    }

    /**
     * 修改应收款月份报
     */
    @PreAuthorize("@ss.hasPermi('poring:poring:edit')")
    @Log(title = "应收款月份报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpReceivableMonthlyReport erpReceivableMonthlyReport)
    {
        return toAjax(erpReceivableMonthlyReportService.updateErpReceivableMonthlyReport(erpReceivableMonthlyReport));
    }

    /**
     * 删除应收款月份报
     */
    @PreAuthorize("@ss.hasPermi('poring:poring:remove')")
    @Log(title = "应收款月份报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(erpReceivableMonthlyReportService.deleteErpReceivableMonthlyReportByIds(ids));
    }
}
